<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>货架标签页</title>

    <script src="/js/jquery.min.js?v=2.1.4"></script>

    <script src="/js/bootstrap.min.js?v=3.3.6"></script>

    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
</head>
<head th:include="include :: header"></head>
<body>
<style>
    .tab-content {padding:19px;}

</style>

<ul id="myTab" class="nav nav-tabs">
    <li class="active" >
        <a href="#A" data-toggle="tab" onclick="load('A')">
            A
        </a>
    </li>
    <li><a href="#B" data-toggle="tab" onclick="load('B')">B</a></li>

    <li><a href="#C" data-toggle="tab" onclick="load('C')">C</a></li>

    <li><a href="#D" data-toggle="tab" onclick="load('D')">D</a></li>

</ul>
<div id="myTabContent" class="tab-content ">
    <div class="tab-pane fade in active" id="A">

    </div>
    <div class="tab-pane fade" id="B">


    </div>
    <div class="tab-pane fade" id="C">


    </div>
    <div class="tab-pane fade" id="D">


    </div>
</div>
<div th:include="include :: footer"></div>
<script  type="text/javascript">
    $(function() {
        load("A");
    });
    function load(num) {
        $.ajax({
            cache : true,
            type : "GET",
            url : "/goods/tGoodsShelf/shelf",
            data : {shelfArea:num},// 你的formid
            async : false,
            error : function(request) {
                parent.layer.alert("Connection error");
            },
            success : function(data) {

                var html=""


                for (var i = 0; i <data.length ; i++) {
                    var provider = "";
                    if(data[i].providerId==null||data[i].providerId==undefined){
                        provider="添加供应商"
                    }else {
                        provider=data[i].providerId;
                        $.ajax({
                            cache : true,
                            type : "GET",
                            url : "/provider/providerInfo/providerById",
                            data : {providerId:provider},// 你的formid
                            async : false,
                            error : function(request) {
                                parent.layer.alert("Connection error");
                            },
                            success : function(data) {
                                provider=data
                            }
                        })
                    }
                    if(data[i].shelfLine==1){
                        html+="        <div class='row' style='margin-top:19px;'>" +
                            "            <div class='col-md-4 col-xs-4 col-sm-4'" +
                            "                 style=''>" +
                            "                <div class='btn-group' style='width:90%;margin-top:-1px;'>\n" +
                            "                    <button type='button' class='btn btn-default' style='width:20%;background:#f9f9f9;'  onclick='query("+data[i].shelfId+")'>"+data[i].shelfNumber+"</button>\n" +
                            "                    <button type='button' class='btn btn-default' style='width:80%;' onclick='edit("+data[i].shelfId+")'>"+provider+"</button>\n" +
                            "                </div>\n" +
                            "            </div>"
                    }else if (data[i].shelfLine==3){
                        html+="<div class='col-md-4 col-xs-4 col-sm-4'" +
                            "                 style=''>\n" +
                            "                <div class='btn-group' style='width:90%;margin-top:-1px;'>\n" +
                            "                    <button type='button' class='btn btn-default' style='width:20%;background:#f9f9f9;' onclick='query("+data[i].shelfId+")'>"+data[i].shelfNumber+"</button>\n" +
                            "                    <button type='button' class='btn btn-default' style='width:80%;' onclick='edit("+data[i].shelfId+")'>"+provider+"</button>\n" +
                            "                </div>" +
                            "            </div>" +
                            "        </div>"
                    } else {
                        html+=" <div class='col-md-4 col-xs-4 col-sm-4'" +
                            "                 style=''>\n" +
                            "                <div class='btn-group' style='width:90%;margin-top:-1px;'>\n" +
                            "                    <button type='button' class='btn btn-default' style='width:20%;background:#f9f9f9;' onclick='query("+data[i].shelfId+")'>"+data[i].shelfNumber+"</button>\n" +
                            "                    <button type='button' class='btn btn-default' style='width:80%;' onclick='edit("+data[i].shelfId+")'>"+provider+"</button>\n" +
                            "                </div>" +
                            "            </div>"
                    }
                }
                $("#"+num).html(html)
            }
        });
    }

    function edit(id) {
        layer.open({
            type : 2,
            title : '编辑',
            maxmin : true,
            shadeClose : false, // 点击遮罩关闭层
            area : [ '800px', '520px' ],
            content :  '/goods/tGoodsShelf/edit/' + id // iframe的url
        });
    }
    function reLoad() {
        $('#exampleTable').bootstrapTable('refresh');
    }
    function query(id) {
        window.location.href="/goods/tGoodsShelf/queryAllocation/"+id

    }

</script>

</body>
</html>